package com.example.role.service.serviceimpl;

import com.example.role.dao.OfficeDao;
import com.example.role.mapper.OfficeMapper;
import com.example.role.pojo.Office;
import com.example.role.service.IOffice;
import com.example.role.util.ServerResponse;
import com.example.role.util.TableServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class OfficeImpl implements IOffice {
@Autowired
OfficeDao officeDao;

    //增加单位，调用dao层进行添加
    @Override
    public int addOffice(Office order) {
        return officeDao.addOffice(order);
    }
    //查询单位列表，调用dao层进行查询
    @Override
    public Office getOfficeById(String id) {
        return officeDao.getOfficeById(id);
    }
    //删除
    @Override
    public int deleteOffice(String id) {
        return officeDao.deleteOffice(id);
    }
    //修改
    @Override
    public int updateOffice(Office order) {
        return officeDao.updateOffice(order);
    }

//    @Override
//    public TableServerResponse queryOffice(Integer page, Integer limit) {
//         //开启分页
//        PageHelper.startPage(page,limit);
//        //查询
//
//        List<Office> queryOffice = officeMapper.queryOffice();
//        //查询条数
//        PageInfo pageInfo=new PageInfo(queryOffice);
//        long total=pageInfo.getTotal();
//
//        return TableServerResponse.createSuccess(0,queryOffice,total);
//
//    }
//
//    @Override
//    public ServerResponse addOffice(Office office) {
//        int insert = officeMapper.insert(office);
//        if(insert>0){
//            return ServerResponse.createSuccess();
//        }else{
//            return ServerResponse.createError();
//        }
//
//    }
//
//    @Override
//    public ServerResponse updaOffice(Office office) {
//        int updaOffice = officeMapper.updateByPrimaryKey(office);
//            if(updaOffice>0){
//                return ServerResponse.createSuccess("修改成功");
//            }else{
//                return ServerResponse.createError("修改位通过");
//            }
//
//
//    }

}
